package cn.suimg.neo4j.controller;

import cn.hutool.core.thread.ThreadUtil;
import cn.suimg.neo4j.dto.NeoQueryRequest;
import cn.suimg.neo4j.dto.NeoQueryResult;
import cn.suimg.neo4j.service.MusicService;
import cn.suimg.neo4j.service.Neo4jService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@AllArgsConstructor
@RequestMapping(value = "neo4j",produces="application/json;charset=UTF-8")
public class Neo4jController {

    private Neo4jService neo4jService;

    private MusicService musicService;

    @PostMapping("dynamicQuery")
    public NeoQueryResult dynamicQuery(@RequestBody NeoQueryRequest queryEntity){
        return neo4jService.dynamicQuery(queryEntity);
    }

    @GetMapping("downloadSingerImageZip")
    public String downloadSingerImageZip(Integer singerId){
        return musicService.downloadSingerImagesZip(singerId);
    }


    @GetMapping("importSingerData")
    public String importSingerData(Integer singerId){
        ThreadUtil.execAsync(() -> musicService.addSingerFullData(singerId));
        return "ok";
    }
}
